<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>围棋-登录</title>
  <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
  <div>
    姓名：<input id="name" type="text"><br>
    密码：<input id="pwd" type="text"><br>
    <button id="btn">登录</button>
  </div>
<script>
$('#btn').click(function() {
  var name = $("#name").val();
  var pwd = $("#pwd").val();
  $.ajax({
    url: '/users/login',
    data: {
      username: name,
      pwd: pwd
    },
    method: 'get',
    success: function(res) {
      if (!res.data) {
        alert('登录失败');
      } else {
        // alert('登录成功');
        window.location.href = '/rooms.html';
      }
    }
  });
});
</script>
</body>
</html>